Skip to content

Commit

Permalink
build: move EXTRA vars directly into targets
Browse files Browse the repository at this point in the history
  • Loading branch information
kmk3 committed Jan 22, 2024
1 parent 0c2be35 commit 54057e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/prog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
# The includer should probably define PROG and TARGET and may also want to
# define EXTRA_HDRS and EXTRA_OBJS and extend CLEANFILES.

HDRS := $(sort $(wildcard $(MOD_DIR)/*.h)) $(EXTRA_HDRS)
HDRS := $(sort $(wildcard $(MOD_DIR)/*.h))
SRCS := $(sort $(wildcard $(MOD_DIR)/*.c))
OBJS := $(SRCS:.c=.o) $(EXTRA_OBJS)
OBJS := $(SRCS:.c=.o)

.PHONY: all
all: $(TARGET)

%.o : %.c $(HDRS) $(ROOT)/config.mk
%.o : %.c $(HDRS) $(EXTRA_HDRS) $(ROOT)/config.mk
$(CC) $(PROG_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

$(PROG): $(OBJS) $(ROOT)/config.mk
$(CC) $(PROG_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(PROG): $(OBJS) $(EXTRA_OBJS) $(ROOT)/config.mk
$(CC) $(PROG_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(EXTRA_OBJS) $(LIBS)

.PHONY: clean
clean:; rm -fr $(PROG) $(CLEANFILES)
10 changes: 5 additions & 5 deletions src/so.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
# The includer should probably define SO and TARGET and may also want to define
# EXTRA_HDRS and EXTRA_OBJS and extend CLEANFILES.

HDRS := $(sort $(wildcard $(MOD_DIR)/*.h)) $(EXTRA_HDRS)
HDRS := $(sort $(wildcard $(MOD_DIR)/*.h))
SRCS := $(sort $(wildcard $(MOD_DIR)/*.c))
OBJS := $(SRCS:.c=.o) $(EXTRA_OBJS)
OBJS := $(SRCS:.c=.o)

.PHONY: all
all: $(TARGET)

%.o : %.c $(HDRS) $(ROOT)/config.mk
%.o : %.c $(HDRS) $(EXTRA_HDRS) $(ROOT)/config.mk
$(CC) $(SO_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

$(SO): $(OBJS) $(ROOT)/config.mk
$(CC) $(SO_LDFLAGS) -shared $(LDFLAGS) -o $@ $(OBJS) -ldl
$(SO): $(OBJS) $(EXTRA_OBJS) $(ROOT)/config.mk
$(CC) $(SO_LDFLAGS) -shared $(LDFLAGS) -o $@ $(OBJS) $(EXTRA_OBJS) -ldl

.PHONY: clean
clean:; rm -fr $(SO) $(CLEANFILES)

0 comments on commit 54057e1

Please sign in to comment.