Skip to content

Commit

Permalink
Tidying up Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldebree committed Sep 18, 2023
1 parent b549371 commit 5756566
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ ifneq ($(TARGET),DEBUG)
CC_FLAGS := $(CC_FLAGS) -O2 -flto -DNDEBUG
endif

.PHONY: clean
.PHONY: ubuntu
.PHONY: dist

# Rule to compile .o from .cpp
%.o: %.cpp
Expand Down Expand Up @@ -90,6 +87,7 @@ $(ARTIFACTS_FOLDER)/config:
mkdir -p $@

# Create a distribution folder with executables and resources
.PHONY: dist
dist: $(EXE) $(DIST_FOLDER)
strip $(EXE)
mv $(EXE) $(DIST_FOLDER)
Expand All @@ -108,17 +106,33 @@ $(ARTIFACTS_FOLDER):
$(DIST_FOLDER):
mkdir -p $@

.PHONY: clean
clean:
rm ${OBJ} || true
rm -rf $(ARTIFACTS_FOLDER) || true

# Local development specific

.PHONY: run
run: $(EXE)
$(EXE)

.PHONY: debug
debug: $(EXE)
cd $(ARTIFACTS_FOLDER) && lldb $(APP_NAME)

# For local development with ccls, make this file first
compile_commands.json: clean
bear -- make TARGET=DEBUG PLATFORM=$(PLATFORM)

# --- DOCKER BUILDS ---

TMP_CONTAINER=sf2_build_tmp

# Compile with the Ubuntu image
BUILD_IMAGE_UBUNTU=sidfactory2/build-ubuntu

.PHONY: ubuntu
ubuntu:
docker container rm $(TMP_CONTAINER) || true
docker build -t $(BUILD_IMAGE_UBUNTU) .
Expand All @@ -129,6 +143,7 @@ ubuntu:
# Compile with the Archlinux image
BUILD_IMAGE_ARCHLINUX=sidfactory2/build-archlinux

.PHONY: archlinux
archlinux:
docker container rm $(TMP_CONTAINER) || true
docker build -t $(BUILD_IMAGE_ARCHLINUX) -f Dockerfile.Archlinux .
Expand Down
10 changes: 5 additions & 5 deletions macos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ LINKER_FLAGS=\
-Wl,-rpath,@executable_path/../Frameworks \
-target $(TARGET)

.PHONY: clean
.PHONY: tmp
.PHONY: dmg
.PHONY: app

# Rule to compile .o from .cpp
%.o: %.cpp
$(CC) $(CC_FLAGS) -c $< -o $@
Expand All @@ -69,6 +64,7 @@ $(EXE): $(OBJ) $(ARTIFACTS_FOLDER)
strip $(EXE)

# Make universal binary
.PHONY: universal
universal: | clean $(EXE)
rm ${OBJ} || true
mv $(EXE) $(EXE)_x86
Expand All @@ -77,16 +73,19 @@ universal: | clean $(EXE)
lipo -create -output $(EXE) $(EXE)_x86 $(EXE)_arm
rm $(EXE)_x86 $(EXE)_arm

.PHONY: app
app: $(APP)

# ----------------------------------------------------

# Step 1: "make raw" to create a "raw" DMG
.PHONY: raw
raw: $(DMG_RAW)

# Step 2: Mount tmp.dmg, lay it out manually, unmount

# Step 3: "make dmg" to finalize the DMG
.PHONY: dmg
dmg: $(DMG)

# ---------------------------------------------------
Expand Down Expand Up @@ -156,6 +155,7 @@ $(ARTIFACTS_FOLDER)/%.html: %.md
$(ARTIFACTS_FOLDER):
mkdir -p $@

.PHONY: clean
clean:
rm ${OBJ} || true
rm -rf $(ARTIFACTS_FOLDER)

0 comments on commit 5756566

Please sign in to comment.