Pages

Saturday, December 19, 2020

Automatically connect to a network via dhcpcd on Arch Linux

 Activate service of name dhcpcd@interface.service

 You can get the name of your network interface withe ip link command. For example:

ip link

sudo systemctl enable dhcpcd@enp2s0.service


How to use output from shell commands on a Makefile

The way I found the simplest: by using eval to declare a new variable.

Example:

test: test.c flags

    gcc -o test test.c $(FLAGS)

flags:

    $(eval FLAGS=$(shell echo "-lm"))

And test.c being:

#include <math.h>
#include <stdio.h>

int main() {
  printf("%.0f squared is: %.0f.\n", 2.0, pow(2, 2));
  return 0;

}

It correctly prints: 

 2 squared is: 4.