2 Commits c6c1387ebb ... 366df24595

Author SHA1 Message Date
  scossu 366df24595 Add outdir to LD flags. 1 year ago
  scossu d3cf9698d3 Output libraries in bin/. 1 year ago
1 changed files with 17 additions and 13 deletions
  1. 17 13
      Makefile

+ 17 - 13
Makefile

@@ -13,13 +13,14 @@ PREFIX ?= /usr/local
 bindir = $(PREFIX)/bin
 libdir = $(PREFIX)/lib
 includedir = $(PREFIX)/include/lsup
+outdir = ./bin
 
 INCLUDE = -I. -Iinclude -I$(includedir)
 # Link all ext libraries statically.
 CFLAGS += -std=gnu11 -Wall -fPIC -MMD $(INCLUDE)
 DBG_CFLAGS = -Itest -O0 -g3 -DDEBUG
-LDFLAGS = -L. -L$(libdir) -llsuprdf
-DBG_LDFLAGS = -L. -L$(libdir) -llsuprdf_dbg
+LDFLAGS = -L. -L$(outdir) -L$(libdir) -llsuprdf
+DBG_LDFLAGS = -L. -L$(outdir) -L$(libdir) -llsuprdf_dbg
 
 SRC = $(wildcard src/*.c)
 OBJ = $(SRC:.c=.o)
@@ -27,8 +28,12 @@ DBG_OBJ = $(SRC:.c=_dbg.o)
 
 TEST_SRC = $(wildcard test/*.c) test.c
 
-LIBS = liblsuprepo.a liblsuprepo.so
-DBG_LIBS = liblsuprepo_dbg.a liblsuprepo_dbg.so
+STATIC_LIB = $(outdir)/liblsuprepo.a
+DYN_LIB = $(outdir)/liblsuprepo.so
+STATIC_DBG_LIB = $(outdir)/liblsuprepo_dbg.a
+DYN_DBG_LIB = $(outdir)/liblsuprepo_dbg.so
+LIBS = $(STATIC_LIB) $(DYN_LIB)
+DBG_LIBS = $(STATIC_DBG_LIB) $(DYN_DBG_LIB)
 
 
 ## Environment.
@@ -56,19 +61,19 @@ lib: $(LIBS)
 debug: $(DBG_LIBS)
 
 
-liblsuprepo.a: $(OBJ)
+$(STATIC_LIB): $(OBJ)
 	$(AR) rs $@ $^
 
 
-liblsuprepo.so: $(OBJ)
+$(DYN_LIB): $(OBJ)
 	$(CC) -shared $(LDFLAGS) -o $@ $^
 
 
-liblsuprepo_dbg.a: $(DBG_OBJ)
+$(STATIC_DBG_LIB): $(DBG_OBJ)
 	$(AR) rs $@ $^
 
 
-liblsuprepo_dbg.so: $(DBG_OBJ)
+$(DYN_DBG_LIB): $(DBG_OBJ)
 	$(CC) -shared $(LDFLAGS) -o $@ $^
 
 
@@ -80,19 +85,18 @@ liblsuprepo_dbg.so: $(DBG_OBJ)
 install: lib ## Install default libraries to $PREFIX. May require sudo.
 	mkdir -p $(DESTDIR)$(libdir)
 	mkdir -p $(DESTDIR)$(includedir)
-	cp liblsuprepo.* $(DESTDIR)$(libdir) && \
+	cp $(LIBS) $(DESTDIR)$(libdir) && \
 		cp include/*.h $(EXT_H) $(DESTDIR)$(includedir)
 
 
 debug_install: install debug ## Install default and debug libraries.
-	cp liblsuprdf_dbg.{a,so} $(DESTDIR)$(libdir)
-	
+	cp $(DBG_LIBS) $(DESTDIR)$(libdir)
 
 
 .PHONY: clean
 clean:
-	rm -rf src/*.[aod] ./*.{a,o,d,so}
-	rm -f bin/test*
+	rm -rf ./*.[aod] src/*.[aod]
+	rm -f $(LIBS) bin/test*
 
 
 .PHONY: uninstall