aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-19 21:58:44 +0100
committerMattias Andrée <maandree@kth.se>2022-02-19 21:58:44 +0100
commit2580c00f380dddb0c8403d2f30851388973eebf3 (patch)
treec8f13f45d9894d39e3d4f1c9e87c86aa767aa26b
parentImprove makefile + minor fixes and improvements (diff)
downloadlibred-2580c00f380dddb0c8403d2f30851388973eebf3.tar.gz
libred-2580c00f380dddb0c8403d2f30851388973eebf3.tar.bz2
libred-2580c00f380dddb0c8403d2f30851388973eebf3.tar.xz
Improve makefile1.0.2.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--Makefile35
-rw-r--r--config.mk4
-rw-r--r--mk/linux.mk2
-rw-r--r--mk/macos.mk4
-rw-r--r--mk/windows.mk4
5 files changed, 29 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 719b3bc..2ae68f6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,5 @@
.POSIX:
-LIB_MAJOR = 1
-LIB_MINOR = 0
-LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
-
-
CONFIGFILE = config.mk
include $(CONFIGFILE)
@@ -15,12 +10,21 @@ OS = linux
include mk/$(OS).mk
+LIB_MAJOR = 1
+LIB_MINOR = 0
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+
+
OBJ =\
solar.o\
blackbody.o
LOBJ = $(OBJ:.o=.lo)
+MAN0 = libred.h.0
+MAN3 = libred_check_timetravel.3 libred_get_colour.3 libred_solar_elevation.3
+MAN7 = libred.7
+
all: libred.a libred.$(LIBEXT)
solar.o: libred.h
@@ -33,8 +37,8 @@ generate-table.o: blackbody.c 10deg-xy.i libred.h
10deg-rgb.i: generate-table 10deg
./generate-table > $@
-.o:
- $(CC) -o $@ $< $(LDFLAGS)
+generate-table: generate-table.o
+ $(CC) -o $@ generate-table.o $(LDFLAGS)
.c.o:
$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
@@ -43,7 +47,7 @@ generate-table.o: blackbody.c 10deg-xy.i libred.h
$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
libred.a: $(OBJ)
- -@rm -f -- $@
+ -rm -f -- $@
$(AR) rc $@ $(OBJ)
$(AR) s $@
@@ -58,12 +62,13 @@ install: libred.a libred.$(LIBEXT)
mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
cp -- libred.a "$(DESTDIR)$(PREFIX)/lib"
cp -- libred.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBMINOREXT)"
+ $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBMINOREXT)"
ln -sf -- libred.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBMAJOREXT)"
ln -sf -- libred.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBEXT)"
cp -- libred.h "$(DESTDIR)$(PREFIX)/include"
- cp -- libred.h.0 "$(DESTDIR)$(MANPREFIX)/man0"
- cp -- libred_check_timetravel.3 libred_get_colour.3 libred_solar_elevation.3 "$(DESTDIR)$(MANPREFIX)/man3"
- cp -- libred.7 "$(DESTDIR)$(MANPREFIX)/man7"
+ cp -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0"
+ cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"
+ cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"
uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libred.a"
@@ -71,11 +76,9 @@ uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBMINOREXT)"
-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libred.$(LIBEXT)"
-rm -f -- "$(DESTDIR)$(PREFIX)/include/libred.h"
- -rm -f -- "$(DESTDIR)$(MANPREFIX)/man0/libred.h.0"
- -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/libred_check_timetravel.3"
- -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/libred_get_colour.3"
- -rm -f -- "$(DESTDIR)$(MANPREFIX)/man3/libred_solar_elevation.3"
- -rm -f -- "$(DESTDIR)$(MANPREFIX)/man7/libred.7"
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man0/" && rm -f -- $(MAN0)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man3/" && rm -f -- $(MAN3)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man7/" && rm -f -- $(MAN7)
clean:
-rm -f -- generate-table *.i *.o *.a *.lo *.su *.so *.dll *.dylib
diff --git a/config.mk b/config.mk
index 9b1bc39..9aa4de7 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,8 @@
PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
-CC = cc
+CC = c99
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
-CFLAGS = -std=c99 -Wall -O2
+CFLAGS = -Wall -O2
LDFLAGS = -lm -s
diff --git a/mk/linux.mk b/mk/linux.mk
index c180f9b..28f3551 100644
--- a/mk/linux.mk
+++ b/mk/linux.mk
@@ -2,3 +2,5 @@ LIBEXT = so
LIBFLAGS = -shared -Wl,-soname,libred.$(LIBEXT).$(LIB_MAJOR)
LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR)
LIBMINOREXT = $(LIBEXT).$(LIB_VERSION)
+
+FIX_INSTALL_NAME = :
diff --git a/mk/macos.mk b/mk/macos.mk
index bd92de6..b465e72 100644
--- a/mk/macos.mk
+++ b/mk/macos.mk
@@ -1,4 +1,6 @@
LIBEXT = dylib
-LIBFLAGS = -dynamiclib
+LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION)
LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
LIBMINOREXT = $(LIB_VERSION).$(LIBEXT)
+
+FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libred.$(LIBMAJOREXT)"
diff --git a/mk/windows.mk b/mk/windows.mk
index e9602e1..ed5ec8d 100644
--- a/mk/windows.mk
+++ b/mk/windows.mk
@@ -1,4 +1,6 @@
LIBEXT = dll
-LIBFLAGS = -mdll
+LIBFLAGS = -shared
LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
LIBMINOREXT = $(LIB_VERSION).$(LIBEXT)
+
+FIX_INSTALL_NAME = :