added stuff
This commit is contained in:
parent
e8d9044d2b
commit
9d0ebdfbd0
907 changed files with 70990 additions and 0 deletions
42
nyx/flake/templates/c/makefile
Normal file
42
nyx/flake/templates/c/makefile
Normal file
|
@ -0,0 +1,42 @@
|
|||
PREFIX ?= /usr/local # this is overriden by the derivation makeFlags
|
||||
BIN_DIR ?= $(PREFIX)/bin
|
||||
|
||||
|
||||
TARGET_EXEC ?= foo-bar
|
||||
BUILD_DIR ?= ./build
|
||||
SRC_DIRS ?= ./src
|
||||
|
||||
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c)
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
|
||||
|
||||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
||||
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
|
||||
|
||||
# c source
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# c++ source
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: clean install run
|
||||
|
||||
clean:
|
||||
rm -r $(BUILD_DIR)
|
||||
|
||||
install: $(BUILD_DIR)/$(TARGET_EXEC)
|
||||
install -Dt $(BIN_DIR) $<
|
||||
|
||||
run: $(BUILD_DIR)/$(TARGET_EXEC)
|
||||
./$<
|
||||
|
||||
-include $(DEPS)
|
Loading…
Add table
Add a link
Reference in a new issue