From 7ccd0de67e9b51ce7e568d675f3b7ce9bbeb42a2 Mon Sep 17 00:00:00 2001 From: Wojciech Graj Date: Mon, 27 Mar 2023 17:45:16 +0200 Subject: [PATCH] Finish converting to meson build system. --- Makefile | 83 ------------------------------------------------ README.md | 12 +++---- meson.build | 1 - util/winbuild.sh | 6 ++-- util/wininit.sh | 2 +- 5 files changed, 9 insertions(+), 95 deletions(-) delete mode 100755 Makefile diff --git a/Makefile b/Makefile deleted file mode 100755 index b5a02af..0000000 --- a/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -TARGET := orbvis - -CC := gcc -WARNINGS := -Wall -Wextra -Wpedantic -Wdouble-promotion -Wstrict-prototypes -Wshadow -Wduplicated-cond -Wduplicated-branches -Wjump-misses-init -Wnull-dereference -Wrestrict -Wlogical-op -Walloc-zero -Wformat-security -Wformat-signedness -Winit-self -Wlogical-op -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wswitch-enum -Wundef -Wwrite-strings -Wno-discarded-qualifiers -CFLAGS := -O3 `pkg-config --cflags gtk+-3.0 cglm libcurl epoxy` -std=c11 -LDFLAGS := -lm `pkg-config --libs gtk+-3.0 cglm libcurl epoxy` -COMMANDS := $(CC) pkg-config xxd sed -PACKAGES := gtk+-3.0 cglm libcurl epoxy - -ifeq ($(MAKECMDGOALS),windows) - CFLAGS += -march=core2 -flto - LDFLAGS += -lopengl32 -mwindows -flto -else - LDFLAGS += -ldl - ifeq ($(MAKECMDGOALS),debug) - CFLAGS += -march=native -fsanitize=address -fsanitize=undefined -g -ftrapv -fno-omit-frame-pointer -lrt -DDEBUG - LDFLAGS += -fsanitize=address -fsanitize=undefined -g -ftrapv -fno-omit-frame-pointer -lrt - else - CFLAGS += -flto - LDFLAGS += -flto - ifeq ($(MAKECMDGOALS),release) - CFLAGS += -march=core2 - else - CFLAGS += -march=native - endif - endif -endif - -BUILD_DIR := ./obj -SRC_DIRS := ./src -LIB_DIRS := ./lib -RES_DIRS := ./res - -.PHONY: clean - -LIB_SRCS := $(shell find $(LIB_DIRS) -name '*.c') -SRCS := $(shell find $(SRC_DIRS) -name '*.c') -RES := $(shell find $(RES_DIRS) -type f) -RES_SRCS := $(RES:%=$(BUILD_DIR)/%.c) - -OBJS := $(RES_SRCS:$(BUILD_DIR)/%=$(BUILD_DIR)/%.r.o) $(SRCS:%=$(BUILD_DIR)/%.s.o) $(LIB_SRCS:%=$(BUILD_DIR)/%.l.o) - -INC_DIRS := $(shell find $(SRC_DIRS) $(LIB_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -$(TARGET): $(COMMANDS) $(PACKAGES) $(OBJS) - $(CC) $(OBJS) -o $@ $(LDFLAGS) - -$(COMMANDS): - @if ! [ $$(command -v $@) ]; then \ - echo "Missing command: $@"; \ - false; \ - fi - -$(PACKAGES): - @if ! pkg-config --exists $@; then \ - echo "Missing package: $@"; \ - false; \ - fi - -$(BUILD_DIR)/%.c.l.o: %.c - mkdir -p $(@D) - $(CC) -o $@ $(CFLAGS) -I$( $@ - -%.c.r.o: %.c - mkdir -p $(@D) - $(CC) $(INC_FLAGS) $(CFLAGS) $(WARNINGS) -c $< -o $@ - -clean: - rm -rf $(BUILD_DIR) - rm -f $(TARGET) - -windows: $(TARGET) -debug: $(TARGET) -release: $(TARGET) diff --git a/README.md b/README.md index 59a613c..173a0ed 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,15 @@ View and propagate the full CelesTrak satellite catalog in realtime. ### Linux -The following packages have to be installed prior to compilation: `gcc pkg-config gtk+-3.0 cglm libcurl epoxy`. On Debian-based systems, run the following command to install them: +The following packages have to be installed prior to compilation: `gcc pkg-config gtk+-3.0 cglm libcurl epoxy meson`. On Debian-based systems, run the following command to install them: ``` -apt-get install gcc pkg-config libgtk-3-dev libcglm-dev libcurl4-openssl-dev libepoxy-dev +apt-get install gcc pkg-config libgtk-3-dev libcglm-dev libcurl4-openssl-dev libepoxy-dev meson ``` -The makefile automatically checks that the above dependencies are satisfied. -To compile, simply: +To compile: ``` -make +meson builddir +meson compile -C builddir ``` To run the program: ``` @@ -27,7 +27,7 @@ To run the program: Windows binaries are provided with github releases. These releases provide the executable `bin/orbvis.exe`, which cannot be moved from the directory structure, but a shortcut can be created and used. -To compile for windows, MSYS2 is used. First verify that all required packages are installed by calling `util/wininit.sh`, then compile with `util/winbuild.sh`. This creates the `release` directory containing windows binaries and all other required files. +If you wish to compile for windows yourself, use MSYS2. First verify that all required packages are installed by calling `util/wininit.sh`, then compile with `util/winbuild.sh`. This creates the `release` directory containing windows binaries and all other required files. ## License diff --git a/meson.build b/meson.build index ebbab5b..754abec 100644 --- a/meson.build +++ b/meson.build @@ -21,7 +21,6 @@ deps = [ dependency('libcurl'), dependency('epoxy'), cc.find_library('m', required : false), - cc.find_library('dl', required : false), ] subdir('src') diff --git a/util/winbuild.sh b/util/winbuild.sh index 7c0ca9a..27c5cf2 100755 --- a/util/winbuild.sh +++ b/util/winbuild.sh @@ -3,9 +3,8 @@ BIN_NAME=orbvis.exe MINGW_PATH=/c/msys64/mingw64 -rm -rf release -make clean -make -j8 windows +meson setup builddir +meson compile -C builddir mkdir -p release/bin cd release/bin mv ../../$BIN_NAME $BIN_NAME @@ -28,4 +27,3 @@ cd ../.. cp ../util/README_WIN.txt README.txt cp ../LICENSE LICENSE.txt cd .. -make clean diff --git a/util/wininit.sh b/util/wininit.sh index d4f35a8..c4e48b0 100755 --- a/util/wininit.sh +++ b/util/wininit.sh @@ -2,4 +2,4 @@ pacman -Syu pacman -S mingw-w64-x86_64-toolchain -pacman -S mingw-w64-x86_64-curl mingw-w64-x86_64-cglm mingw-w64-x86_64-gtk3 mingw-w64-x86_64-libepoxy make vim +pacman -S mingw-w64-x86_64-curl mingw-w64-x86_64-cglm mingw-w64-x86_64-gtk3 mingw-w64-x86_64-libepoxy mingw-w64-x86_64-meson vim