sgl

view Makefile.in @ 41:f4ea3a88b05a

macos build fixes. Patch by Andrew Woods
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 25 Jan 2025 22:26:40 +0200
parents 3d6ee9fb9ac1
children
line source
1 src = $(wildcard src/*.c)
2 msrc = $(wildcard src/*.m)
3 obj = $(src:.c=.o) $(msrc:.m=.o)
4 dep = $(src:.c=.d)
5 lib_a = libsgl.a
6 soname = libsgl.so.$(somajor)
7 lib_so = $(lib_so_$(sys))
9 somajor = 0
10 sominor = 0
12 lib_so_unix = $(soname).$(sominor)
13 lib_so_mac = libsgl.dylib
15 sharedopt_unix = -shared -Wl,-soname,$(soname)
16 sharedopt_mac = -dynamiclib
18 ifeq ($(shell uname -s), Darwin)
19 sys = mac
20 else
21 sys = unix
22 endif
24 AR = ar
25 CC = gcc
26 CFLAGS = -pedantic -Wall -g -fPIC -Iinclude -Isrc $(wsys_cflags) $(CFLAGS_extra)
27 LDFLAGS = $(wsys_libs)
29 ifeq ($(shell uname -s), Darwin)
30 CFLAGS += -DGL_SILENCE_DEPRECATION
31 endif
33 .PHONY: all
34 all: $(lib_so) $(lib_a)
36 $(lib_a): $(obj)
37 $(AR) rcs $@ $(obj)
39 $(lib_so): $(obj)
40 $(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS)
42 %.o: %.m
43 $(CC) $(CFLAGS) -c -o $@ $<
45 -include $(dep)
47 %.d: %.c
48 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
50 .PHONY: clean
51 clean:
52 rm -f $(obj) $(dep) $(lib_so) $(lib_a)
54 .PHONY: install
55 install:
56 mkdir -p $(PREFIX)/include $(PREFIX)/lib
57 cp $(lib_a) $(PREFIX)/lib/$(lib_a)
58 cp $(lib_so) $(PREFIX)/lib/$(lib_so)
59 cp include/sgl.h $(PREFIX)/include/sgl.h
61 .PHONY: uninstall
62 uninstall:
63 rm -f $(PREFIX)/lib/$(lib_a)
64 rm -f $(PREFIX)/lib/$(lib_so)
65 rm -f $(PREFIX)/include/sgl.h