-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libut]support shared build and more #84
Open
marguerite
wants to merge
3
commits into
troydhanson:master
Choose a base branch
from
marguerite:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
OBJS=libut.a | ||
all: $(OBJS) | ||
SOURCES = src/libut.c src/ringbuf.c src/utmm.c src/utvector.c | ||
HEADERS = include/libut.h include/ringbuf.h include/utarray.h include/uthash.h include/utlist.h include/utmm.h include/utringbuffer.h include/utstring.h include/utvector.h | ||
OBJS=$(SOURCES:.c=.o) | ||
all: libut.a libut.so.2.0.1 | ||
INCDIR=./include | ||
LIBDIR=/usr/lib | ||
CFLAGS+=-I$(INCDIR) | ||
CFLAGS+=-Wall -Wextra | ||
CFLAGS+=-Wall -Wextra -Werror -fPIC | ||
CFLAGS+=-g | ||
CFLAGS+=$(OPTFLAGS) | ||
|
||
libut.a: libut.o utvector.o utmm.o ringbuf.o | ||
libut.a: $(OBJS) | ||
ar r $@ $^ | ||
|
||
libut.o: src/libut.c $(INCDIR)/libut.h | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< | ||
|
||
utvector.o: src/utvector.c $(INCDIR)/utvector.h | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< | ||
|
||
utmm.o: src/utmm.c $(INCDIR)/utmm.h | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< | ||
|
||
ringbuf.o: src/ringbuf.c $(INCDIR)/ringbuf.h | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< | ||
libut.so.2.0.1: $(OBJS) | ||
$(CC) $(CFLAGS) -shared -Wl,-soname,libut.so.2 $^ -o $@ | ||
|
||
.PHONY: clean tests install | ||
|
||
clean: | ||
rm -f $(OBJS) *.o | ||
rm -f *.o *.a *.so* | ||
make -C tests clean | ||
|
||
tests: libut.a | ||
make -C tests | ||
|
||
install: libut.a | ||
cp $< /usr/local/lib | ||
install: libut.a libut.so.2.0.1 | ||
mkdir -p $(DESTDIR)$(LIBDIR) | ||
mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig | ||
mkdir -p $(DESTDIR)/usr/include | ||
cp libut.a $(DESTDIR)$(LIBDIR) | ||
cp libut.so.2.0.1 $(DESTDIR)$(LIBDIR) | ||
ln -sf $(LIBDIR)/libut.so.2.0.1 $(DESTDIR)$(LIBDIR)/libut.so.2 | ||
ln -sf $(LIBDIR)/libut.so.2.0.1 $(DESTDIR)$(LIBDIR)/libut.so | ||
cp ./include/*.h $(DESTDIR)/usr/include | ||
sed -i -e "s|VERSION|2.0.1|" uthash.pc.in | ||
sed -i -e "s|LIBDIR|$(LIBDIR)|" uthash.pc.in | ||
cp uthash.pc.in $(DESTDIR)$(LIBDIR)/pkgconfig/uthash.pc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
prefix=/usr | ||
libdir=LIBDIR | ||
includedir=/usr/include | ||
|
||
Name: uthash | ||
Description: C macros for hash tables and more | ||
Version: VERSION | ||
Libs: -L${libdir} -lut | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes seem unwanted: I don't think
OPTFLAGS
is defined anywhere, and I'm not convinced that-fPIC
is sufficiently portable/correct (as opposed to just letting the compiler do whatever it'd do by default).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPTFLAGS
is an environment variable $RPM_OPT_FLAGS visible when building a RPM. that is, packager can pass itmake OPTFLAGS="$RPM_OPT_FLAGS"
in specfile (like debian rules). On non-RPM system, it will be nothing. It will not harm. And packagers will create such downstream patches anyway if we don't add it upstream.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
$(OPTFLAGS)
seems harmless, I think (if no version of Make really complains about undefined variables). I'm still leery of messing with-fPIC
, though.Also, I just checked, and the Debian package doesn't install
libut.a
at all. I don't think the corresponding SUSE package should try to installlibut.{a,so}
either, unless some user is actually demanding it (see again: extraordinary evidence).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, SUSE/openSUSE didn't install libut.a either. The build has it, but we deleted it later. I think it's common that Linux distributions don't ship static libraries. But things may be different under other cases.
About fPIC, I have little knowledge of it. But I think it's almost a common principle across distribution (position independent codes). I saw many downstream patches adding this in my packaging life. I found this explains it well: http://stackoverflow.com/questions/5311515/gcc-fpic-option