git @ Cat's Eye Technologies linapple / allow-installless-build
Allow ASSET_DIR and RESOURCE_INIT_DIR to be set at build time. Chris Pressey 3 years ago
4 changed file(s) with 17 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
44
55 # Where does this get installed
66 PREFIX := /usr/local
7 ASSET_DIR := $(PREFIX)/share/$(PACKAGE)
7
8 # Where assets (font file, etc) are read from
9 # (You can build a version that loads assets from the source tree with: ASSET_DIR=`pwd`/res make )
10 ASSET_DIR ?= $(PREFIX)/share/$(PACKAGE)
11
12 # Where default versions of resource files (linapple.conf, etc) are obtained from initially
13 # (You can build a version that copies resources from the source tree with: RESOURCE_INIT_DIR=`pwd`/res make )
14 RESOURCE_INIT_DIR ?= /etc/linapple
815
916 #Compiler and Linker
1017 CC := g++
4148 #DEBUGGING
4249 #CFLAGS := -Wall -O0 -ggdb -ansi -c -finstrument-functions
4350 #OPTIMIZED
44 CFLAGS := -Wall -O3 -ansi -c -DASSET_DIR=\"$(ASSET_DIR)\"
51 CFLAGS := -Wall -O3 -ansi -c -DASSET_DIR=\"$(ASSET_DIR)\" -DRESOURCE_INIT_DIR=\"$(RESOURCE_INIT_DIR)\"
4552 CFLAGS += $(SDL_CFLAGS)
4653 CFLAGS += $(CURL_CFLAGS)
4754
99 #define CONF_DIRECTORY_NAME "/conf/"
1010 #define SAVED_DIRECTORY_NAME "/saved/"
1111 #define FTP_DIRECTORY_NAME "/ftp/"
12 #define INSTALL_DIRECTORY_NAME "/etc/linapple/"
12 #ifdef RESOURCE_INIT_DIR
13 #define INSTALL_DIRECTORY_NAME RESOURCE_INIT_DIR "/"
14 #else
15 #define INSTALL_DIRECTORY_NAME "/etc/linapple/"
16 #endif
1317 #define MAX_FILENAME_LENGTH 255
1418
1519 class Config
4444 SDL_Surface *surf;
4545 char *path = (char *)SDL_malloc(sizeof(char[PATH_MAX]));
4646 if (NULL == path) {
47 fprintf(stderr, "Asset_Init: Allocating path: %s\n", SDL_GetError());
47 fprintf(stderr, "Asset_LoadBMP: Allocating path: %s\n", SDL_GetError());
4848 return NULL;
4949 }
5050
3535
3636 void Config::ChangeToUserDirectory()
3737 {
38 if(chdir((GetHomePath() + USER_DIRECTORY_NAME).c_str()))
38 if(chdir(GetUserFilePath().c_str()))
3939 {
4040
41 cout << "Cannot switch to home directory ('" << GetHomePath().c_str() << "')" << std::endl;
41 cout << "Cannot switch to user directory ('" << GetUserFilePath().c_str() << "')" << std::endl;
4242 }
4343 }
4444